package com.spring.springboot.server;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.spring.springboot.entity.UserEntity;
import com.spring.springboot.jpa.UserJPA;

/**
*@author LSY
*Time: 2018年12月5日下午8:10:04
*
*
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class UserService {

	@Autowired
    private UserJPA userRepository;
    /**
     * 消息队列业务逻辑实现
     */
   /* @Autowired
    private QueueMessageService queueMessageService;*/

    /**
     * 保存用户
     * 并写入消息队列
     * @param userEntity
     * @return
     */
    public Long save(UserEntity userEntity) throws Exception
    {
        /**
         * 保存用户
         */
        userRepository.save(userEntity);
        /**
         * 将消息写入消息队列
         */
        //queueMessageService.send(userEntity.getId(), ExchangeEnum.USER_REGISTER, QueueEnum.USER_REGISTER);

        return userEntity.getId();
    }
}
